package com.lsp.base.utils.rxpreference;

import com.alibaba.fastjson.JSON;
import java.lang.reflect.Type;

/**
 * json  object 转换
 *
 * @author com.lsp.ibxs
 * @created 16/11/11 10:57
 */
public class JsonConverterProvider {

  private static JsonConverter JSON_CONVERTER = new FastJsonConverter();

  public static JsonConverter jsonConverter() {
    return JSON_CONVERTER;
  }

  private static class FastJsonConverter implements JsonConverter {

    @Override public String toJson(Object object) {
      return JSON.toJSONString(object);
    }

    @Override public <T> T fromJson(String jsonString, Type type) {
      return JSON.parseObject(jsonString, type);
    }
  }
}
